package org.kkk.sandbox.sandbox;


import org.kkk.sandbox.sandbox.impl.CodeSandboxTemplate;
import org.kkk.sandbox.sandbox.impl.JavaDockerCodeSandbox;
import org.kkk.sandbox.sandbox.impl.JavaNativeCodeSandbox;

/**
 * 代码沙箱工厂（根据字符串参数创建指定的代码沙箱实例）
 */
public class CodeSandboxFactory {

    /**
     * 创建代码沙箱示例
     *
     * @param type 沙箱类型
     * @return
     */
    public static CodeSandbox newInstance(String type) {
        switch (type) {
            case "native":
                System.out.println("native");
                return new JavaNativeCodeSandbox();
            case "docker":
                System.out.println("docker");return new JavaDockerCodeSandbox();
            default:
                System.out.println("default");
                return new CodeSandboxTemplate();
        }
    }
}
